package adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.hospitalmanagementapp.PayModel
import com.example.hospitalmanagementapp.R

class PersonAdapterUtil(context:Context):
    RecyclerView.Adapter<PersonAdapterUtil.PersonalHolder>() {
    lateinit var dataList: MutableList<PayModel>
    private lateinit var listener:(position:Int)->Unit
    fun setListener(listener:(position:Int)->Unit){
        this.listener=listener
    }
    private val context:Context=context

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PersonalHolder {
        return PersonalHolder(LayoutInflater.from(context).inflate(R.layout.pay_item, null))
    }

    override fun onBindViewHolder(holder: PersonalHolder, position: Int) {
      holder.payImageView.setImageResource(R.mipmap.pay_service)
      holder.payText.text= dataList[position].textView
    }

    override fun getItemCount(): Int {
        return if (null==dataList) 0 else dataList.size
    }
    inner class PersonalHolder(view: View):RecyclerView.ViewHolder(view){
    var payImageView=view.findViewById<ImageView>(R.id.pay_image)
    val payText=view.findViewById<TextView>(R.id.pay_data)
    }
}